package DaEr3_1;

import java.util.Scanner;

public class WorkPro {
    public static void main(String[] args) {
        int []arr=new int[5];
       WorkPro.Input(arr);
       WorkPro.ArrSort(arr);
        WorkPro.Output(arr);
    }

    public static void Input(int[] arr) {
        for (int i = 0; i <arr.length ; i++) {
            System.out.println("请输入第"+(i+1)+"个数：");
            Scanner scanner = new Scanner(System.in);
            arr[i] = scanner.nextInt();
        }
    }
    public static void Output(int[] arr) {
        System.out.println("排序后的顺序：");
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(" " + arr[i]);
        }
    }

    public static void ArrSort(int[] arr) {
        int x,r;
        for (int i = 0; i < arr.length; i++) {
            x=i;
            for (int j = i; j < arr.length; j++) {
                if (arr[j]<arr[x]){
                    x=j;
                }
            }
            if (x!=i){
                r=arr[x];
                arr[x]=arr[i];
                arr[i]=r;
            }
        }
    }
}
